package com.sky.service.common.impl;

import com.sky.properties.AliOssProperties;
import com.sky.result.Result;
import com.sky.service.common.CommonService;
import com.sky.utils.AliOssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.UUID;

@Service
public class CommonServiceImpl implements CommonService {
    @Autowired
    private AliOssUtil aliOssUtil;
    @Override
    public Result<String> upload(byte[] bytes , String fileName) {
        String suffix = fileName.substring(fileName.lastIndexOf("."));
        fileName = UUID.randomUUID().toString().replace("-", "").concat(suffix);
        String url = aliOssUtil.upload(bytes, fileName);
        return Result.success(url);
    }
}
